﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;

namespace SocketChat.control
{
    public partial class ColorSelect : UserControl
    {
        List<FillColor> lstTipsData;

        public ColorSelect()
        {
            InitializeComponent();
            //初始化数据
            lstTipsData = new List<FillColor>() { 
                new FillColor(){ Color = new SolidColorBrush(Colors.Black), Name="黑色"},
                new FillColor(){ Color = new SolidColorBrush(Colors.Red), Name="红色"},
                new FillColor(){ Color = new SolidColorBrush(Colors.Blue), Name="蓝色"},
                new FillColor(){ Color = new SolidColorBrush(Colors.Green),Name="绿色"},
                new FillColor(){ Color = new SolidColorBrush(Colors.Magenta), Name="洋红"},               
                new FillColor(){ Color = new SolidColorBrush(Colors.Orange), Name="橙色"},
            };

            this.Loaded += new RoutedEventHandler(ColorSelect_Loaded);
        }

        void ColorSelect_Loaded(object sender, RoutedEventArgs e)
        {
            //throw new NotImplementedException();
            itemsTip.ItemsSource = lstTipsData;
        }


        private void GoToEnter(object sender, MouseEventArgs e)
        {
            VisualStateManager.GoToState(this, "Enter", false);
        }

        private void GoToLeave(object sender, MouseEventArgs e)
        {
            VisualStateManager.GoToState(this, "Leave", false);
        }

        /// <summary>
        /// 点击后更换颜色
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void ChangeColor(object sender, MouseButtonEventArgs e)
        {
            rColor.Fill = (sender as Rectangle).Fill;
            VisualStateManager.GoToState(this, "Leave", false);
        }
    }

    /// <summary>
    /// 测试实体类
    /// </summary>
    public class FillColor
    {
        public SolidColorBrush Color { set; get; }
        public string Name { set; get; }
    }
}
